package practice;

public class PerfectNumber {
    public static void main(String[] args) {
        findFerfectNum();
    }
    public static void findFerfectNum() {
        for(int i = 1;i <= 1000;i++){
            boolean x = Sum(i);
            if(x){
                System.out.println(i + " ");
            }
        }
    }
    public static boolean Sum(int n) {
        int sum = 0;
        for(int i = 1;i <= n / 2;i++){
            if(n % i == 0){
                sum += i;
            }
        }
        if(sum == n){
            return true;
        } else {
            return false;
        }
    }
}
